<?php
// +----------------------------------------------------------------------
// | Bwsaas
// +----------------------------------------------------------------------
// | Copyright (c) 2015~2020 http://www.buwangyun.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Gitee ( https://gitee.com/buwangyun/bwsaas )
// +----------------------------------------------------------------------
// | Author: buwangyun <hnlg666@163.com>
// +----------------------------------------------------------------------
// | Date: 2020-9-28 10:55:00
// +----------------------------------------------------------------------

namespace bw\gatewayworker;



use app\admin\model\Admin;
use bw\Common;

/** 基础
 * Class Common
 * @package app\bwmall\model
 */
class  Base
{

    public $client = null;
    public $data = [];
    public $identity = '';

    public function __construct($client = null,$param=[])
    {
        $this->client = $client;
        $this->data = $param;

    }



    public function msg($options=[]){
        $defoalut = [
            'identify'=>$this->identity,
            'type'=>'',
            'data'=>[],
            'message'=>'',
        ];
        return array_merge($defoalut,$options);
    }


    // 代理身份相关的方法
    public function __call($method, $parameters)
    {
        $data=$parameters[0];
        if(!isset($data['send_time']))$data['send_time'] = time();
        return $this->msg(['data'=>$data,'type'=>Common::uncamelize($method),'message'=>$parameters['message'] ?? ""]);
    }


}